package processor;

import model.SusongTag;
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.selector.Selectable;
import util.Mytime;

import java.util.List;

//import static processor.LoginProcessor.isRedirectedToLoginPage;


public class SusongPageProcessor {
    public static void processFirmSusong(Page page){
        /**
         * @Description 获得诉讼信息
         * https://www.qichacha.com/firm_3c09b2c37cfd655f2030878a9f3e6fab.html#susong
         */
//        System.out.println("开始解析法律诉讼");
//        if(isRedirectedToLoginPage(page)){
//            return;
//        }
        List<Selectable> nodes = page.getHtml().xpath("//section[@class='panel b-a clear m_dataTab']//div//a").nodes();
        SusongTag susongTag = new SusongTag();
        susongTag.setCompany_unique(page.getRequest().getExtra("unique").toString());
        susongTag.setZhixing(nodes.get(0).xpath("/a/allText()").toString());
        susongTag.setShixin(nodes.get(1).xpath("/a/allText()").toString());
        susongTag.setWenshu(nodes.get(2).xpath("/a/allText()").toString());
        susongTag.setFayuan(nodes.get(3).xpath("/a/allText()").toString());
        susongTag.setKaiting(nodes.get(4).xpath("/a/allText()").toString());
        susongTag.setSongda(nodes.get(5).xpath("/a/allText()").toString());
        susongTag.setSifa(nodes.get(6).xpath("/a/allText()").toString());
        susongTag.setCreatedTime(Mytime.getTime());
//        System.out.println("诉讼信息抓取完成");
        page.putField("SusongTag", susongTag);
    }
}
